const  cd_装备类型词典={'ws': '剑', 'wa': '斧子', 'wd': '匕首', 'wm': '狼牙棒', 'wp': '矛', 'wb': '弓', 'ww': '魔杖', 'wt': '法杖', 'wg': '枪', 'wc': '弩', 'ah': '重甲', 'am': '中甲', 'al': '轻甲', 'hh': '头盔', 'hm': '游侠头', 'hl': '法师帽', 'gh': '铁护手', 'gl': '护腕', 'bh': '重鞋', 'bl': '轻鞋', 'uh': '草药', 'up': '药水', 'us': '法术', 'xs': '护盾', 'xr': '戒指', 'xa': '项链', 'wi': '乐器', 'xx': '光环', 'xc': '披风', 'xf': '使魔', 'fm': '使魔'}
const cd_英雄词典={'argon': '阿尔贡', 'ashley': '阿什利', 'atlab_aang': '魔法?', 'atlab_sokka': '武器?', 'bjorn': '比约恩', 'donovan': '多诺万',
    'hemma': '赫马', 'king': '国王', 'leather': '皮革?', 'lilu': '里路', 'polonia': '波洛尼亚', 'rudo': '鲁多', 'sia': '西亚', 'yami': '亚米'}

async function get_json() {
    try {
        const response = await fetch('./heroes.json');
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }
        const data = await response.json();
        // console.log(data);
        return data;
    } catch (error) {
        console.error('There was a problem with the fetch operation:', error);
        throw error;
    }
}

export async function get_heroes_data() {
    let heroData;
    try {

        heroData = await get_json();

        // console.log(heroData);
    } catch (error) {
        // Handle error
        console.error(error);
    }

    // for (let i in hero_data){
    //     console.log(i)
    //     new_hero_data=hero_data[i]
    // }
    // console.log(new_hero_data)
    const newHeroData = {};

    for (const i in heroData) {
        const chBulk = heroData[i]['bulkTypes'].split(',').map(k => cd_装备类型词典[k]);
        newHeroData[cd_英雄词典[i]] = heroData[i]
        newHeroData[cd_英雄词典[i]]['bulkTypes']=chBulk
    }

    // console.log(newHeroData);
    return newHeroData;



}
